from django.db import models

# Create your models here.

#建立用户数据库（员工类）
class User(models.Model):
    '''
    员工类
    username:                                  用户昵称
    year:                                      年龄
    region:                                    所在地区
    signature：                                个性签名
    entry_time:                                入职时间
    email:                                     邮箱(账号用户名)*    
    password:                                  账号密码          
    name:                                      员工姓名
    gender:                                    性别
    department:                                部门
    position:                                  岗位
    role:                                      角色
    telephone:                                 手机号码
    '''
    # 创建用户属性
    username = models.CharField(max_length=256,null=True)
    year = models.CharField(max_length=30,null=True)
    region = models.CharField(max_length=64,null=True)
    signature = models.CharField(max_length=256,null=True)
    entry_time = models.CharField(max_length=30,null=True)
    email = models.CharField(max_length=30,primary_key=True)
    password = models.CharField(max_length=30,null=True)
    name = models.CharField(max_length=30,null=True)
    gender = models.CharField(max_length=10,null=True)
    department = models.CharField(max_length=30,null=True)
    position = models.CharField(max_length=30,null=True)
    right_level = models.IntegerField(null=True)
    telephone = models.CharField(max_length=20,null=True)
    # profile_picture = models.ImageField() 头像，备选
    pass

# 建立角色类
class Role(models.Model):
    '''
    role:                                      角色*                             
    right_level:                               权限
    managementflag                             是否为管理员
    remark:                                    备注
    '''
    role = models.CharField(max_length=30,primary_key=True)
    right_level = models.IntegerField(null=True)
    managementflag = models.CharField(max_length = 30,null=True)
    remark = models.CharField(max_length=256,null=True)
    pass


# 建立验证码类
class code(models.Model):
    '''
    验证码类
    account:                                   用户账号即邮箱 
    confirm_code:                              验证码   
    '''
    # 创建属性
    account = models.CharField(max_length=30)
    confirm_code = models.CharField(max_length=6)
    pass

# 建立仓库类
class Warehouse(models.Model):
    '''
    仓库类
    code:                                      仓库编码*
    name:                                      仓库名称
    address:                                   仓库地址
    stock:                                     仓库库存  
    capacity:                                  仓库容量                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
    principal:                                 仓库负责人
    p_telephone:                               负责人手机号码
    p_email:                                   负责人邮箱
    remark:                                    备注
    '''
    code = models.CharField(max_length=30,primary_key=True)
    name = models.CharField(max_length=30,null=True)
    address = models.CharField(max_length=30,null=True)
    stock = models.IntegerField(null=True)
    capacity = models.IntegerField(null=True)
    principal = models.CharField(max_length=30,null=True)
    p_telephone = models.CharField(max_length=30,null=True)
    p_email = models.CharField(max_length=30,null=True)
    remark = models.CharField(max_length=256,null=True)
    pass


# 建立物料类
class Material(models.Model):
    '''
    物料类
    name:                                      物料名称
    type:                                      物料类别
    code:                                      物料编码 *
    number:                                    物料数量
    price:                                     物料单价
    Warehouse:                                 所属仓库
    inventory_number:                          入库单号
    in_time:                                   入库时间
    remark:                                    备注
    '''
    name = models.CharField(max_length = 30,null=True)
    type = models.CharField(max_length = 30,null=True)
    code = models.CharField(max_length = 30,primary_key = True)
    number = models.IntegerField(null=True)
    price = models.CharField(max_length=30,null=True)
    Warehouse = models.CharField(max_length=30,null=True)
    inventory_number = models.CharField(max_length=30,null=True)
    in_time = models.DateField(null=True)
    remark = models.CharField(max_length=256,null=True)
    pass

# 创建日志类
class Log(models.Model):
    '''
    日志类
    type:                                        事件类型
    time:                                        发生时间
    affair:                                      具体事件
    ''' 
    type = models.CharField(max_length=30,null=True)
    time = models.CharField(max_length=30,null=True)
    affair = models.CharField(max_length=256,null=True)
    pass

# 创建部门类
class Department(models.Model):
    '''
    name:                                       部门名称*
    number:                                     部门人数
    principal:                                  仓库负责人
    p_telephone:                                负责人手机号码
    p_email:                                    负责人邮箱
    '''
    name = models.CharField(max_length=30,primary_key=True)
    number = models.IntegerField(null=True)
    principal = models.CharField(max_length=30,null=True)
    p_telephone = models.CharField(max_length=30,null=True)
    p_email = models.CharField(max_length=30,null=True)
    pass



# 创建入库类
class IB(models.Model):
    '''
    inventory_number:                           入库单号*
    inventory_type:                             物料类型
    material_name:                              物料名称
    material_code:                              物料编码
    inventory_quantity:                         入库量
    price:                                      物料单价
    dest_warehouse:                             入库仓库
    approval_status:                            审批状态
    creation_time:                              创建时间
    principal:                                  负责人
    email:                                      负责人邮箱
    remark:                                     备注
    '''
    inventory_number = models.CharField(max_length=30,primary_key=True)
    inventory_type = models.CharField(max_length=30,null=True)
    material_name = models.CharField(max_length=30,null=True)
    material_code = models.CharField(max_length=30,null=True)
    inventory_quantity = models.IntegerField(null=True)
    price = models.CharField(max_length=30,null=True)
    dest_warehouse = models.CharField(max_length=30,null=True)
    approval_status = models.CharField(max_length=30,null=True)
    creation_time = models.DateField(max_length=30,null=True)
    principal = models.CharField(max_length=30,null=True)
    email = models.CharField(max_length=30,null=True)
    remark = models.CharField(max_length=256,null=True)
    pass

# 创建出库类
class OB(models.Model):
    '''
    outBound_number:                            出库单号*
    outBound_type:                              物料类型
    material_name:                              物料名称
    material_code:                              物料编码
    outBound_quantity:                          出库量
    price:                                      物料单价
    ori_warehouse:                              出库仓库
    approval_status:                            审批状态
    creation_time:                              创建时间
    principal:                                  负责人
    email:                                      负责人邮箱
    remark:                                     备注
    '''
    outBound_number = models.CharField(max_length=30,primary_key=True)
    outBound_type = models.CharField(max_length=30,null=True)
    material_name = models.CharField(max_length=30,null=True)
    material_code = models.CharField(max_length=30,null=True)
    outBound_quantity = models.IntegerField(null=True)
    price = models.CharField(max_length=30,null=True)
    ori_warehouse = models.CharField(max_length=30,null=True)
    approval_status = models.CharField(max_length=30,null=True)
    creation_time = models.DateField(max_length=30,null=True)
    principal = models.CharField(max_length=30,null=True)
    email = models.CharField(max_length=30,null=True)
    remark = models.CharField(max_length=256,null=True)
    pass

# 创建通知类
class Notice(models.Model):
    '''
    date:                                       日期
    materialName:                               物料名称
    IBOB:                                       入库/出库
    warehouse:                                  仓库
    number                                      数量
    '''
    date = models.DateField(max_length=30,null=True)
    materialName = models.CharField(max_length=30,null=True)
    IBOB = models.CharField(max_length=30,null=True)
    warehouse = models.CharField(max_length=30,null=True)
    number = models.IntegerField(null=True)
    pass

# 创建报表类
class Report(models.Model):
    '''
    warehouse:                                  仓库
    year_month:                                 年月份
    materialName:                               物料名称
    initialNumber:                              月初库存数量
    IBNumber:                                   本月入库数量
    OBNumber:                                   本月出库数量
    finalNumber:                                月末结存数量
    initialMoney:                               月初库存总金额
    IBMoney:                                    本月入库总金额
    OBMoney:                                    本月出库总金额
    finalMoney:                                 月末结存总金额
    price:                                      单价
    '''
    warehouse =  models.CharField(max_length=30,null = True)                             
    year_month = models.DateField(max_length=30,null = True)                                      
    materialName = models.CharField(max_length=30,null = True)
    initialNumber = models.IntegerField(null=True)
    IBNumber = models.IntegerField(null=True)
    OBNumber = models.IntegerField(null=True)
    finalNumber = models.IntegerField(null=True)
    initialMoney = models.IntegerField(null=True)
    IBMoney = models.IntegerField(null=True)
    OBMoney = models.IntegerField(null=True)
    finalMoney = models.IntegerField(null=True)
    price = models.IntegerField(null=True)
    pass

#创建价格类
class Price(models.Model):
    '''
        materialName:                           物料名称*
        price:                                  价格
    '''
    materialName = models.CharField(max_length=30,primary_key=True)
    price = models.IntegerField(null=True)   
    pass

# 创建上班打卡类
class UpPunch(models.Model):
    email = models.CharField(max_length=30,null=True)
    time = models.DateField(null=True)
    pass

# 创建下班打卡类
class DownPunch(models.Model):
    '''
        email:                               用户邮箱
        time:                                打卡日期
    '''
    email = models.CharField(max_length=30,null=True)
    time = models.DateField(null=True)
    pass


# 创建物料分类库
class MaterialType(models.Model):
    '''
        type_name:                            物料类型名称
        remark:                               备注
    '''
    type_name = models.CharField(max_length=30,null=True)
    remark = models.CharField(max_length=256,null=True)
    pass


# 包含所有员工信息（用于认证）
class AllReport(models.Model):
    '''
    所有员工类
    email:                                     邮箱(账号用户名)*
    name:                                      员工姓名
    gender:                                    性别
    department:                                部门
    position:                                  岗位
    telephone:                                 手机号码
    '''
    # 创建用户属性
    email = models.CharField(max_length=30,primary_key=True)
    name = models.CharField(max_length=30,null=True)
    gender = models.CharField(max_length=10)
    department = models.CharField(max_length=30,null=True)
    position = models.CharField(max_length=30,null=True)
    telephone = models.CharField(max_length=20,null=True)